package com.cb.domain.scheduing;

import java.text.ParseException;
import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.cb.core.command.QueryFilter;
import com.cb.core.util.DateUtil;
import com.cb.domain.model.order.Policy;
import com.cb.domain.service.order.PolicyManager;

public class CheckPolicyJob {
	@Autowired
	private PolicyManager policyManager;
	public void enblePolicy(){
		Date yesterday=null;
		try {
			yesterday = DateUtil.addDate(new Date(), -1);
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		QueryFilter filter=new QueryFilter();
		filter.addFilter("Q_status_L_EQ", "1");
		filter.addFilter("Q_enfdateTicket_D_LE", DateUtil.convertDateToString(yesterday));
		List<Policy> policies= policyManager.getAll(filter).getList();
		for (Policy policy : policies) {
			policy.setStatus(0l);
			policyManager.save(policy);
		}
		
	}

}
